package com.bawei.park2302.visit

import com.bawei.lib_base.utils.utils.mvi.BaseViewModel
import com.bawei.lib_base.utils.utils.request.RequestType
import com.bawei.lib_base.utils.utils.utils.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class VisitViewModel @Inject constructor(val apiService: ApiService) : BaseViewModel<VisitIntent>(){
    override fun handelIntent(it: VisitIntent) {
        when(it){
            is VisitIntent.visit -> httpRequest(apiService.visit())

            is VisitIntent.visitStatus -> httpRequest(apiService.visitStatus(it.status))

            is VisitIntent.visitAdd -> httpRequest(apiService.visitAdd(mapToBody(it.visitBeanItem)))

            is VisitIntent.visitName -> httpRequest(apiService.visitName(it.name))

            is VisitIntent.visitDetail -> httpRequest(apiService.visitDetail(it.id),RequestType.DETAIL)

            is VisitIntent.visitApprove -> httpRequest(apiService.visitApprove(it.id),RequestType.APPROVE)

            is VisitIntent.visitReject -> httpRequest(apiService.visitReject(it.id),RequestType.REJECT)
        }
    }
}